package cn.chrilwe.autocreatetable.start.config;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import cn.chrilwe.autocreatetable.start.config.Config.Mark;
import cn.chrilwe.autocreatetable.start.processor.CustomLifecycleProcessor;

@Configuration
public class EnableAutoCreateTableConfiguration {
	
	@Autowired
	private DataSource dataSource;
	
	@Value("${ibatis.entity.path}")
	private String entityPath; 

	@Bean("lifecycleProcessor")
	@ConditionalOnBean(Mark.class)
	public CustomLifecycleProcessor processor() {
		
		return new CustomLifecycleProcessor(dataSource,entityPath);
	}

}
